<template>
  <div class="container" style="width:99%;margin-top:-25px;">
    <!-- 查询条件 -->
    <div class="query-box">
      <el-form :model="queryBox" status-icon ref="queryBox">
        <el-row>
          <el-col :span="4">
            <div class="depart-box">
              <div class="slect-title">物料类别</div>
              <el-select clearable filterable v-model="queryBox.materielType" filterable>
                <el-option
                  v-for="item in materiel_type_option"
                  :key="item.key"
                  :label="item.value"
                  :value="item.key"
                ></el-option>
              </el-select>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="depart-box">
              <el-form-item label prop="customerNumber">
              <el-input v-model="queryBox.customerNumber" placeholder="客户编号">
                <template slot="prepend">物料编码物料编码</template>
              </el-input>
            </el-form-item>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="depart-box">
              <div class="slect-title">获取方式</div>
              <el-select
                clearable
                v-model="queryBox.allotType"
                filterable       
              >
                <el-option
                  v-for="item in student_data_from_type_options"
                  :key="item.key"
                  :label="item.value"
                  :value="item.key"
                ></el-option>
              </el-select>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="depart-box">
              <div class="slect-title">客户进展</div>
              <el-form-item @change="student_progress_change">
                <el-select clearable filterable v-model="queryBox.customerProgress" placeholder="请选择">
                  <el-option
                    v-for="item in student_progress_options"
                    :key="item.key"
                    :label="item.value"
                    :value="item.key"
                  >{{item.value}}</el-option>
                </el-select>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="4">
            <el-form-item label prop="customerNumber">
              <el-input v-model="queryBox.customerNumber" placeholder="客户编号">
                <template slot="prepend">客户编号</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="from-btns">
        <kt-button
          :label="$t('action.reset')"
          perms="true"
          type="primary"
          @click="reset('queryBox')"
        />
        <kt-button
          :label="$t('action.search')"
          perms="true"
          type="primary"
          @click="search"
        />
      </div>
    </div>
    <!-- 批量删除按钮 -->
    <div class="add-btns fl">
      <kt-button
        :label="$t('批量上传')"
        perms="MaterialMange:MaterialPackage:upload"
        type="primary"
        @click="addAllSelection"
      />
    </div>
    <div class="fr">
      <kt-button
        :label="$t('新增')"
        type="primary"
        perms="MaterialMange:MaterialPackage:add"
        @click="handleNewADD"
      ></kt-button>
    </div>
    <!--表格内容栏-->
    <div class="btn">
      <Crm-table
        class="table-width"
        MaterialPackage
        width="400"
        :showBatchDelete="false"
        permsSee="customer:chinaedu:see"
        permsEdit="customer:chinaedu:edit"
        :data="pageResult"
        :columns="columns"
        :loading='loading'
        @findPage="findPage"
        @changeSwitch="changeSwitch"
        @handleEdit="handleEdit"
        @handleSee="handleSee"
      ></Crm-table>
    </div>
  </div>
</template>
<script>
import PopupTreeInput from "@/components/PopupTreeInput";
import KtButton from "@/views/Core/KtButton";
import CrmTable from "@/views/Core/CrmTable";
import CrmSwitch from "@/views/Core/CrmSwitch";
import { regionDataPlus } from "element-china-area-data";
import { CodeToText } from "element-china-area-data";
import WebUpload from "@/components/common/upload/WebUpload";
import { baseUrl } from "@/utils/global";
import axios from "axios";
import Cookies from "js-cookie"
export default {
  name: "Chinaedu",
  components: {
    PopupTreeInput,
    CrmTable,
    KtButton,
    CrmSwitch
  },
  data() {
    return {

      // 查询条件
      isopen: [
        {
          value: "解锁",
          label: "1"
        },
        {
          value: "锁定",
          label: "2"
        }
      ],
      queryBox: {
        
      },
      width: 200,
      columns: [
        { type: "index", label: "序号", minWidth: 50 },
        { prop: "agentName", label: "文件名称", minWidth: 120 },
        { prop: "contactPhone", label: "文件大小", minWidth: 100 },
        { prop: "diqu", label: "文件格式", minWidth: 190 },
        { prop: "customerSource", label: "更新时间", minWidth: 100 },
      ],
      pageRequest: { pageNum: 1, pageSize: 10 },
      pageResult: {
        content: []
      },
      materiel_type_option:[],
      loading: false, // 加载标识
      formTitle: "添加",
      tableData: [],
      multipleSelection: [],
      delList: [],
      editVisible: false,
      pageTotal: 0,
      form: {},
      idx: -1,
      uId: 0,
      id: -1,
      loading: true,
      uploadLoading: false,
      showRemoveFile: false,

      imageUrl: "",
      showImgVisible: false,
      uploader: {},
      uploadBtnDisabled: false,
      uploadStaus: "el-icon-upload",
      fileList: [], //显示集合
      chunked: true, //是否开启分片上传
      fileNumLimit: 200, //文件总数
      fileSize: 100 * 1024 * 1024 * 1024, //默认上传文件大小
      chunkSize: 30 * 1024 * 1024, //默认文件片段
      // uploadSuffixUrl: "http://172.16.71.180:8777",
      options: {
        //允许上传的文件
        fileType: "",
        fileUploadUrl: "/upload/chunkUpload/upload_do", //上传地址
        fileCheckUrl: "/upload/chunkUpload/checkFile", //检测文件是否存在url
        checkChunkUrl: "/upload/chunkUpload/checkFile", //检测分片url
        mergeChunksUrl: "/upload/fileRecord/zone/upload/merge/", //合并文件请求地址
        headers: {}
      }
    };
  },
  methods: {
    // 搜索
    search() {
      this.loading=true

      this.pageRequest.pageNum = 1;
      this.findPage(null)
    },
    get_downList(){
      this.$api.user.optionsList({ codeType: "bc_materiel_type" }).then(res => {
        this.materiel_type_option=res.keyValueList
      });
    },
    handleChange(value) {
      console.log(value);
    },
    // 获取分页数据
    findPage: function(data) {
      if (data !== null) {
        this.loading=true
        this.pageRequest = data.pageRequest;
      }
      this.queryBox.pageSize = this.pageRequest.pageSize;
      this.queryBox.pageNum = this.pageRequest.pageNum;
      this.loading=false
    },
    // 重置
    reset(queryBox) {
      this.$refs.queryBox.resetFields();
      this.findPage(null);
    },
    addAllSelection() {
      //添加数据
      this.form = {
        isFilter: "1",
        contentType: "",
        fileSuffix: "",
        fileType: "",
        fileTag: "",
        fileDescribe: ""
      };
      this.formTitle = "上传文件";
      this.editVisible = true;
    },
  },
  mounted() {
    this.get_downList()
  }
};
</script>
<style >
@import url("../../assets/queryBox.css");
</style>
<style lang='scss' scoped>
.checked-person {
  font-weight: 500;
  display: inline-block;
  text-align: center;
  margin: 3% 0 3% 0;
}
.batchdistribution-pop-tit{
  font-size: 20px;
  font-weight: bold;
  display: inline-block;
  color: #303133;
}
.demo-form-inline{
  width: 90%;
  margin: 0 auto;
  .el-dialog__body .el-input{
    width: 93% !important;
  }
  .el-select{
    width: 100% !important;
  }
  .tit{
    display: inline-block;
    margin-top: 10%;
  }
}
.el-row .el-col{
  margin-left: 0;
}
.query-box .el-row .el-col{
  margin-left: 2%;
}
.el-dialog__wrapper .el-form-item__content{
  margin-left: 0;
}
</style>
<style lang='scss'>
.batchdistribution-pop .el-dialog__header{
  padding: 0 0 0 0 !important;
}
</style>



